package com.huatai.bi.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huatai.bi.entity.DataProcessEntity;
import com.huatai.bi.entity.DataSetParameterEntity;
import com.huatai.bi.entity.DirectDataSetEntity;
import com.huatai.bi.mapper.DataProcessMapper;
import com.huatai.bi.mapper.DataSetParameterMapper;
import com.huatai.bi.mapper.DirectDataSetMapper;
import com.huatai.bi.service.DataSetParameterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
* @author hecai
* @description 针对表【tb_data_set_parameter(参数表)】的数据库操作Service实现
* @createDate 2024-06-14 17:27:42
*/
@Service
public class DataSetParameterServiceImpl extends ServiceImpl<DataSetParameterMapper, DataSetParameterEntity>
    implements DataSetParameterService{

	@Autowired
	DirectDataSetMapper dataSetMapper;
	@Autowired
	DataProcessMapper dataProcessMapper;

	public List<DataSetParameterEntity> listByDtId(Long dtId){
		List<DataSetParameterEntity> list = new ArrayList<>();
		DirectDataSetEntity dataSet = dataSetMapper.selectById(dtId);
		Long dataSetId = dtId;
		//当id是数据加工时,获取原始数据集参数
		if(null == dataSet){
			DataProcessEntity process = dataProcessMapper.selectById(dtId);
			if(null == process){
				return list;
			}else{
				dataSetId = process.getDtId();
			}
		}

		list.addAll(list(Wrappers.lambdaQuery(DataSetParameterEntity.class).eq(DataSetParameterEntity::getDdsId, dataSetId)));
		return list;
	}

}




